<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box"></div>
    <script>
        var  str='123abc123Abc'
        /* 
        目的：将里面的所有的a  变成===666===      123===666===bc123Abc
        */
       //new  RegExp(将要替换的值,全局替换【不区分大小写】)
       var  reg=new  RegExp('a','gi')
       // str.replace(规则,将要替换的值)
       var  newStr=str.replace(reg,'<i style="color:red">===666===</i>')
       console.log(newStr);
       document.querySelector('.box').innerHTML=newStr
    </script>
</body>
</html>